package com.common.weibolib;

import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;

import com.common.android.utils.parser.AbstractArrayParser;

public class ImageListparser extends AbstractArrayParser<Image> {

	@Override
	public ImageList parse(JSONArray array) throws JSONException {
		ImageList imageList = new ImageList();
		ImageParser imageParser = new ImageParser();
		for (int i = 0, len = array.length(); i < len; i++) {
			imageList.add(imageParser.parse(array.getJSONObject(i)));
		}
		return imageList;
	}

	@Override
	public JSONArray toJSONArray(List<Image> group) throws JSONException {
		JSONArray jsonArray = new JSONArray();
		ImageParser imageParser = new ImageParser();
		for (Image item : group) {
			jsonArray.put(imageParser.toJSONObject(item));
		}
		return jsonArray;
	}
}
